import Button from "@/component/Button";
import { createPortal } from "react-dom";
import styles from './style.module.less';

interface IDemoViewProps extends React.VideoHTMLAttributes<HTMLElement> {
  _ref?: React.LegacyRef<HTMLDivElement>,
  container?: HTMLDivElement | null;
  on_minimize?(): void;
  on_maximize?(): void;
  on_close?(): void;
}
export function DemoView(props: IDemoViewProps) {
  const { _ref, container, on_minimize, on_maximize, on_close, ..._p } = props;
  if (!container) return null;
  return createPortal(
    <div className={styles.cam_view} ref={_ref} {..._p}>
      <Button onClick={on_minimize}>
        minimize
      </Button>
      <Button onClick={on_maximize}>
        maximize
      </Button>
      <Button onClick={on_close}>
        x
      </Button>
    </div>,
    container
  )
}